<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
<%@page import="util.DataList, java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Register Yourself</title>
        <script type="text/javascript" src="JavaScript/Javascripts.js"></script>
        <script type="text/javascript">
            function reg_user()
            {
                var reg = "<%=session.getAttribute("reg")%>";
                if(reg != 'null') {
                    if(reg == 'Error') {
                        alert("An error occurred, please try after sometime");
                        <%session.setAttribute("reg", null);%>
                    } else {
                        alert("Username "+reg+" already exists.");
                        <%session.setAttribute("reg", null);%>
                        document.signup.fullname.focus();
                    }
                }
                document.signup.user_type.value="Student";
                noBack();
                }
        </script>
        <link href="CSS/Style.css" rel="stylesheet" type="text/css" />
    </head>
    <body onload="reg_user();" onpageshow="if (event.persisted) noBack();" onunload="">
        <jsp:include page="header.jsp"/>
        <div id="menu_wrapper">
            <div id="menu">
                <ul>
                    <li><a href="home.jsp" target="_parent">Home</a></li>
                    <li><a href="about.jsp" target="_parent">About Us</a></li>
                    <li><a href="discuss.jsp" target="_parent">Discussion</a></li>
                    <%
                                if (session.getAttribute("user") == null) {
                    %>
                    <li><a href="Register.jsp" class="current">Register</a></li>
                    <%} else {%>
                    <li><a href="Control.jsp" target="current">User CP</a></li>
                    <%}%>
                </ul>
            </div> <!-- end of menu -->
        </div><!-- end of menu_wrapper -->
        <div id="content_wrapper">
            <div id="sidebar">
                <jsp:include page="login.jsp"/>
                <jsp:include page="subjects.jsp"/>
            </div> <!-- end of sidebar -->

            <div id="content">

                <div class="content_box">
                    <% List<String> streams = DataList.streams;
                        List<String> subjects = DataList.subjects;
                        List<String> years = DataList.years;
                        if(streams.isEmpty() || subjects.isEmpty() || years.isEmpty()) {%>
                        <h3 align="center">Registration process is temporarily unavailable.<br/>
                            Please try after sometime.<br/>
                            Contact Administrator if you are getting this error for long time.
                        </h3>
                        <% } else {%>
                    <h2>Registration Form:</h2>

                    <form action="./Register" name="signup" method="post" onsubmit="return reg_frm()">
                        <table>
                            <tr>
                                <td>User Type</td>
                                <td>
                                    <input type="radio" name="choose" value="Student" checked="checked" onclick="toggle_user()"/>Student
                                    <input type="radio" name="choose" value="Faculty" onclick="toggle_user()"/>Faculty
                                </td>
                            </tr>
                            <tr>
                                <td><input type="hidden" name="user_type"/>
                                </td>
                            </tr>
                            <tr>
                                <td>Full Name</td>
                                <td><input type="text" name="fullname"/>
                                </td>
                            </tr>
                            <tr>
                                <td>User Name</td>
                                <td><input type="text" name="username"/>
                                </td>
                            </tr>
                            <tr>
                                <td>Password</td>
                                <td><input type="password" name="password" />
                                </td>
                                <td></td>
                            </tr>
                            <tr id="tr_stream">
                                <td>Stream</td>
                                <td>
                                    <select name="stream">
                                    <option>Select</option>
                                    <% 
                                       for(int i = 0; i<streams.size();i++) {
                                            out.print("\t<option>" + streams.get(i) + "</option>\n");
                                        }
                                    %>
                                    </select>
                                </td>
                            </tr>
                            <tr id="tr_year">
                                <td>Year</td>
                                <td>
                                    <select name="year">
                                    <option>Select</option>
                                    <%
                                       for(int i = 0; i<years.size();i++) {
                                            out.print("\t<option>" + years.get(i) + "</option>\n");
                                        }
                                    %>
                                    </select>
                                </td>
                            </tr>
                            <tr id="tr_roll">
                                <td>Roll</td>
                                <td><input type="text" name="roll" />
                                </td>
                                <td></td>
                            </tr>
                            <tr id="tr_subject" style="display:none;">
                                <td>Subject</td>
                                <td>
                                    <select name="subject">
                                    <option>Select</option>
                                    <%
                                       for(int i = 0; i<subjects.size();i++) {
                                            out.print("\t<option>" + subjects.get(i) + "</option>\n");
                                        }
                                    %>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="submit" alt="Sign Up" value="Sign Up"/>
                                </td>
                                <td><input type="reset" alt="Clear" value="Clear"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                    <%}%>
                </div><div class="content_box_bottom"></div>

                <div class="content_box">

                    <h2>Testimonial</h2>

                    <div class="section_w250 float_l">
                        <h3>Praesent sollicitudin</h3>
                        <p>Nullam faucibus volutpat sapien sit amet tristique. Suspendisse venenatis, urna nec rhoncus suscipit, turpis turpis auctor nisi.</p>

                    </div>

                    <div class="section_w250 float_r">
                        <h3>Quisque blandit</h3>
                        <p>Morbi blandit ipsum sed purus vestibulum bibendum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec nibh sed tellus.</p>

                    </div>


                    <div class="cleaner"></div>
                </div><div class="content_box_bottom"></div>

            </div> <!-- end of content -->

            <div class="cleaner"></div>

        </div>

        <jsp:include page="footer.jsp"/>
    </body>
</html>